package cn.tedu._08article.base.response;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class JsonResult {
    @Schema(name = "内部状态码",type = "Integer")
    private Integer state;
    @Schema(name = "提示消息",type = "String")
    private String maessage;
    @Schema(name = "null",type = "Object")
    private Object data;


    public JsonResult(StatusCode statusCode){
        this.state=statusCode.getState();
        this.maessage=statusCode.getMessage();
    }
    public JsonResult(StatusCode statusCode,Object data){
        this.state=statusCode.getState();
        this.maessage=statusCode.getMessage();
        this.data=data;
    }

    public static JsonResult ok(){
        return new JsonResult(StatusCode.OPERATION_SUCCESS);
    }
    public static JsonResult ok(Object data){
        return new JsonResult(StatusCode.OPERATION_SUCCESS,data);
    }
}
